package flc.ast.adapter;

import android.graphics.Color;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import flc.ast.R;
import flc.ast.bean.ResultBean;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;
import stark.common.basic.adaptermutil.StkSingleSpanProvider;

public class ResultAdapter extends StkProviderMultiAdapter<ResultBean> {

    public ResultAdapter() {
        addItemProvider(new StkSingleSpanProvider<>(35));
        addItemProvider(new ResultProvider());
    }

    private class ResultProvider extends BaseItemProvider<ResultBean> {
        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_result;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, ResultBean bean) {
            baseViewHolder.setText(R.id.tvResultItemName, bean.getWord());
            if (bean.isRight()){
                baseViewHolder.setTextColor(R.id.tvResultItemName, Color.parseColor("#00AE5C"));
            }else {
                baseViewHolder.setTextColor(R.id.tvResultItemName, Color.parseColor("#DB331F"));
            }
        }
    }
}
